package com.ljsw.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.MessageClass;
/**
 * 任务信息适配器
 * 作者: 石锚
 * 版本: 1.0
 * 日期: 2015-10-9
 */
public class XinxiAdapter extends BaseAdapter{
	private Context context;
	private ArrayList<MessageClass> list;
	

	public XinxiAdapter(Context context, ArrayList<MessageClass> list) {
		super();
		this.context = context;
		this.list = list;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		ViewHodler hodler;
		if(arg1==null){
			hodler = new ViewHodler();
			arg1 = LayoutInflater.from(context).inflate(R.layout.xinxi_list_item, null);
			hodler.service = (TextView) arg1.findViewById(R.id.service);
			hodler.date = (TextView) arg1.findViewById(R.id.date);
			hodler.line = (TextView) arg1.findViewById(R.id.line);
			hodler.time = (TextView) arg1.findViewById(R.id.time);
			hodler.area = (TextView) arg1.findViewById(R.id.area);
			hodler.stree = (TextView) arg1.findViewById(R.id.stree);
			hodler.type = (TextView) arg1.findViewById(R.id.type);
			arg1.setTag(hodler);
		}else{
			hodler = (ViewHodler) arg1.getTag();
		}
		hodler.service.setText(list.get(arg0).getService());
		hodler.date.setText(list.get(arg0).getDate());
		hodler.line.setText(list.get(arg0).getLine());
		hodler.time.setText(list.get(arg0).getTime());
		hodler.area.setText(list.get(arg0).getArea());
		hodler.stree.setText(list.get(arg0).getStree());
		hodler.type.setText(list.get(arg0).getType());
		return arg1;
	}
	
	static class ViewHodler{
		TextView service,date,line,time,area,stree,type;
	}

}
